AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')

function ENT:Initialize()
	self.Entity:SetModel("models/paintball/paintball.mdl")
	self.Entity:PhysicsInit(SOLID_VPHYSICS)
	self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
	self.Entity:SetSolid(SOLID_VPHYSICS)
	 
	local phys = self.Entity:GetPhysicsObject()
	
		  if (phys:IsValid()) then
			phys:Wake()
		  end
end

function ENT:PhysicsCollide(data,phy)
	local trace = {}
	trace.filter = {self.Entity}
	data.HitNormal = data.HitNormal * -1
	local start = data.HitPos + data.HitNormal
	local endpos = data.HitPos - data.HitNormal
  
	util.Decal("splat"..math.random(1,12),start,endpos)
	self.Entity:EmitSound(Sound("marker/pbhit.wav"))
	if (data.HitEntity:IsPlayer()) then
		StunPlayer(data.HitEntity, math.random(5,20))
		data.HitEntity:TakeDamage(1,self.GetShooter)
		
	end
	self.Entity:Fire("kill", "", 0)
end

function ENT:Touch(ent)
if ent:IsValid() then	
	self.Entity:Fire("kill", "", 0)
	end
end

